<template name='pages' style="">
	<view class="pagesMain" v-show="sum>0">
		<uni-pagination title="" 
		show-icon="false"  
		prevText="上一页" 
		nextText="下一页" 
		:total="sum" 
		:current="current" 
		:showPageSize="true"
		@pageSizeChange="pageSizeChange"
		@change="updatePages"
		>
		</uni-pagination>

	</view>
</template>

<script>

	export default{
		name:'pages',
		data(){
			return{
				
			}
		},
		beforeMount(){
		},
		// 此处定义传入的数据
		props: { 
		    sum: {
		    },
			current:{
				type: [Number, String],
				default: 1
			}
		},
		methods:{
			pageSizeChange(pageSize){
				this.change_page(1,pageSize)
			},
			updatePages(res){
			
				if(res.type == 'next'){
					this.page_add(res.current,res.pageSizeRangeValue)
				}else if(res.type == 'prev'){
					this.page_delete(res.current,res.pageSizeRangeValue)
				}else if(res.type == 'current'){
					this.change_page(res.current,res.pageSizeRangeValue)
				}
			},
		
			/**
			 * 跳转到某页
			 * 
			*/
			change_page(pageName,pageSizeRangeValue){
				var that = this
				this.$emit('updatePage',pageName,pageSizeRangeValue) //(父组件中触发的事件名，要传的变量名)
				//this.$emit('loadData',true) //(父组件中触发的事件名，要传的变量名)
			},
			/**
			 * 跳转到上一页
			 * 
			*/
			page_delete(pageName,pageSizeRangeValue){
				this.$emit('updatePage',pageName,pageSizeRangeValue)
			},
			/**
			 * 跳转到下一页
			 * 
			*/
			page_add(pageName,pageSizeRangeValue){
				this.$emit('updatePage',pageName,pageSizeRangeValue) 
			}
		}
	}
</script>

<style>
	.pagesMain{
		position: relative;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		width: 100%;
		padding: 0px;
		margin-top: auto;
		height: 40px;
	}
</style>
